package com.xauto.pioneer.appuser.model;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by Lemon on 16/4/8.
 */
public class PageInfo extends BaseModel<PageInfo> {

    public int page;
    public int count;

    /** 总数*/
    public int total;
    /** 每页数量*/
//    public int count;
    /** 1-有更多/0-没有更多*/
    public int more;

    public PageInfo() {
    }

    public PageInfo(int page, int count) {
        this.page = page;
        this.count = count;
    }

    public JSONObject getPageInfo(int page, int count) throws JSONException {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("page", page);
        jsonObject.put("count", count);
        return jsonObject;
    }


    @Override
    public PageInfo parse(JSONObject jsonObject) {
        if(jsonObject != null) {
            total = jsonObject.optInt("total");
            count = jsonObject.optInt("count");
            more = jsonObject.optInt("more");
            return this;
        }
        return null;
    }
}
